package com.first.group.oldhouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.first.group.oldhouse.entity.OldHouseImgEntity;
import com.first.group.oldhouse.service.OldHouseImgService;
import com.first.group.common.utils.PageUtils;
import com.first.group.common.utils.R;



/**
 * 这是二手房和租房屋图片表
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-10-14 19:07:46
 */
@RestController
@RequestMapping("oldhouse/oldhouseimg")
public class OldHouseImgController {
    @Autowired
    private OldHouseImgService oldHouseImgService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = oldHouseImgService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{oldImgId}")
    public R info(@PathVariable("oldImgId") Long oldImgId){
		OldHouseImgEntity oldHouseImg = oldHouseImgService.getById(oldImgId);

        return R.ok().put("oldHouseImg", oldHouseImg);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody OldHouseImgEntity oldHouseImg){
		oldHouseImgService.save(oldHouseImg);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody OldHouseImgEntity oldHouseImg){
		oldHouseImgService.updateById(oldHouseImg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] oldImgIds){
		oldHouseImgService.removeByIds(Arrays.asList(oldImgIds));

        return R.ok();
    }

}
